package com.gitee.wsl.ext.list

import com.gitee.wsl.ext.collection.padEnd
import com.gitee.wsl.ext.collection.padStart

inline fun <T> List<T>.padWith(size: Int, inserter: (List<T>) -> List<T>): List<T> {
    var result = this
    while (result.size < size) {
        result = inserter(result)
    }
    return result
}

inline fun <T> List<T>.padEnd(size: Int, padBlock: (Int) -> T): List<T> = asSequence().padEnd(size, padBlock).toList()

fun <T> List<T>.padEnd(size: Int, o: T): List<T> = asSequence().padEnd(size, o).toList()

fun <T> List<T>.padStart(size: Int,  padBlock: (Int) -> T): List<T> = asSequence().padStart(size, padBlock).toList()

fun <T> List<T>.padStart(size: Int, o: T): List<T> = asSequence().padStart(size, o).toList()